<?php

Yii::import('usuarios.models._base.BaseTEmpleado');

class TEmpleado extends BaseTEmpleado {

    /**
     * @return TEmpleado
     */
    public $tipo;
    public $existecap_id;
    public $existecav_id;

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function label($n = 1) {
        return Yii::t('app', 'TEmpleado|TEmpleados', $n);
    }

    public function getHistoryEmpleado($per_id) {
        $criteria = new CDbCriteria;
        $criteria->compare('emp_id', $this->emp_id);
        $criteria->compare('per_id', $this->per_id);
        $criteria->compare('pro_id', $this->pro_id);
        $criteria->compare('cap_id', $this->cap_id);
        $criteria->compare('cav_id', $this->cav_id);
        $criteria->compare('emp_observaciones', $this->emp_observaciones, true);
        $criteria->compare('ees_id', $this->ees_id);
        $criteria->addCondition('t.per_id = :per_id', 'AND');
        $criteria->params = array_merge($criteria->params, array(
            ':per_id' => $per_id));
        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
//            'pagination' => 5
        ));
    }

    public function rules() {
        return array_merge(parent::rules(), array(
            array('cap_id', 'required',  'on' => 'cav'),
            array('cav_id', 'required',  'on' => 'cap'),
        ));
    }

}
